<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>我的钱包</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no,email=no,address=no"/>
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <link rel="stylesheet" href="../css/zy_common.css"/>
    <link rel="stylesheet" href="../css/zy_base.css"/>
    <link rel="stylesheet" href="../js/drop/dropload.css"/>
</head>
<body class="bw">
<div class="pos_f_t bw">
    <div class="indexBox flex_aj" style="height: 4rem;">
        <div class="tac">
            <p class="colw font40" id="wallet"></p>
            <p class="colw font13">余额 （元）</p>
            <a href="./zy_tixian.html" class="dib bw color1 border-r4 w160 h60 lh60 font15 mt40">提现</a>
        </div>
    </div>
    <div class="plr24 h100 lh100 font15 col9 bgf5">明细</div>
    <div class="wallet_tit flex border border-r1 col9 bw">
        <span class="active">全部</span><span>提现</span><span>收入</span>
    </div>
</div>
    <div class="walletBox bw plr24">
        <ul>
            <!--<li class="flex_sb ptb30 bdb">-->
                <!--<div>-->
                    <!--<p><span class="col3 font15">提现</span><span class="col9 font14">（审核中）</span></p>-->
                    <!--<p class="col9 font13 mt10">2018-07-06 17:32</p>-->
                <!--</div>-->
                <!--<span class="color2 font15">-￥50.00</span>-->
            <!--</li>-->
            <!--<li class="flex_sb ptb30 bdb">-->
                <!--<div>-->
                    <!--<p><span class="col3 font15">销售收入</span></p>-->
                    <!--<p class="col9 font13 mt10">2018-07-06 17:32</p>-->
                <!--</div>-->
                <!--<span class="color2 font15">+￥50.00</span>-->
            <!--</li>-->
        </ul>
    </div>
</body>
</html>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/dlc.js"></script>
<script type="text/javascript" src="../js/drop/dropload.min.js"></script>
<script>
    var page = 0;
    // 每页展示10个
    var size = 10;
    var tower,yong;
    var type='';
    $(function () {
        dlctipbox.loading('请稍后');
        dlc_request('/api/walletDetail/findWallet',{id:getLocalData('fd_id')},function (res) {
            dlctipbox.clear();
            if(res.code==1){
                $('#wallet').text(res.data.wallet);
            }
        });

        //切换tab
        $('.wallet_tit span').click(function () {
            var index = $(this).index();
            $(this).addClass('active').siblings().removeClass('active');
            if(index == 0){
                type='';
            }else{
                type=index;
            }
            page=0;
            // 解锁loadDownFn里锁定的情况
            yong.unlock();
            yong.noData(false);
            getData(yong);
        });
        //详情
        $('.walletBox').on('click','li',function () {
            location.href='./zy_tx_details.html?id='+$(this).data('id');
        });
        $('.walletBox').dropload({
            scrollArea : window,
            domUp : {
                domClass   : 'dropload-up',
                domRefresh : '<div class="dropload-refresh">↓下拉刷新</div>',
                domUpdate  : '<div class="dropload-update">↑释放更新</div>',
                domLoad    : '<div class="dropload-load"><span class="loadings"></span>加载中...</div>'
            },
            domDown : {
                domClass   : 'dropload-down',
                domRefresh : '<div class="dropload-refresh">↑上拉加载更多</div>',
                domLoad    : '<div class="dropload-load"><span class="loadings"></span>加载中...</div>',
                domNoData  : '<div class="dropload-noData">暂无更多数据</div>'
            },
            loadUpFn : function(me){
                var str = '';
                var data={
                    page:1,
                    limit:size,
                    userId:getLocalData('fd_id')
                };
                if(type){
                    data.type=type
                }
                dlc_request('/api/walletDetail/wdList',data,function (res) {
                    console.log(res);
                    if(res.code==1){
                        res.data.list.forEach(function (item,index) {
                            str+= '<li class="flex_sb ptb30 bdb" data-id="'+item.id+'">'+
                                '<div>'+
                            '<p><span class="col3 font15">'+(item.type==1?'提现':'销售收入')+'</span>'+(item.type==1?'<span class="col9 font14">（'+(item.status==1?'审核中':item.status==2?'审核失败':item.status==3?'已完成':item.status==4?'提现中':'提现失败')+'）</span>':'')+'</p>'+
                            '<p class="col9 font13 mt10">'+format(item.createTime,'Y-m-d H:i:s')+'</p>'+
                            '</div>'+
                            '<span class="color2 font15">'+(item.type==1?'-':'+')+'￥'+item.money+'</span>'+
                            '</li>';
                        });
                        $('.walletBox ul').html(str);
                        // 每次数据加载完，必须重置
                        me.resetload();
                        // 重置页数，重新获取loadDownFn的数据
                        page = 1;
                        // 解锁loadDownFn里锁定的情况
                        me.unlock();
                        me.noData(false);
                    }
                });
            },
            loadDownFn : function(me){
                yong=me;
                getData(yong);
            },
            threshold : 50
        });
    });
    function getData(me){
        page++;
        if(page==1){
            dlctipbox.loading('载入中');
        }
        // 拼接HTML
        var str = '';
        var data={
            page:page,
            limit:size,
            userId:getLocalData('fd_id')
        };
        if(type){
            data.type=type
        }
        dlc_request('/api/walletDetail/wdList',data,function (res) {
            dlctipbox.clear();
            if(res.code==1){
                var arrLen = res.data.list.length;
                if(arrLen > 0){
                    res.data.list.forEach(function (item,index) {
                        str+= '<li class="flex_sb ptb30 bdb" data-id="'+item.id+'">'+
                            '<div>'+
                            '<p><span class="col3 font15">'+(item.type==1?'提现':'销售收入')+'</span>'+(item.type==1?'<span class="col9 font14">（'+(item.status==1?'审核中':item.status==2?'审核失败':item.status==3?'已完成':item.status==4?'提现中':'提现失败')+'）</span>':'')+'</p>'+
                            '<p class="col9 font13 mt10">'+format(item.createTime,'Y-m-d H:i:s')+'</p>'+
                            '</div>'+
                            '<span class="color2 font15">'+(item.type==1?'-':'+')+'￥'+item.money+'</span>'+
                            '</li>';
                    });
                    // 如果没有数据
                }else{
                    // 锁定
                    me.lock();
                    // 无数据
                    me.noData();
                }
                // 插入数据到页面，放到最后面
                if(page==1){
                    $('.walletBox ul').html(str);
                }else{
                    $('.walletBox ul').append(str);
                }
                // 每次数据插入，必须重置
                me.resetload();
            }
        });
    }
</script>
